package com.example.prolyric;

import java.util.ArrayList;

import com.example.prolyric.songmanager.SongsManager;
import com.example.prolyric.songmanager.Song;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;

public class PlaylistManagerActivity extends ListActivity {
	private Button btnBack , btnAddPlaylist; 
	private SongsManager pm ;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_playlist_manager);
        btnBack = (Button)findViewById(R.id.btn_playlist_manager_back);
        btnAddPlaylist = (Button)findViewById(R.id.btn_playlist_manager_add);
        
        pm = new SongsManager(this);
        ArrayList<String> allPlaylist = pm.getAllPlaylists();
        if(allPlaylist!= null)
        {
        	 String [] playlistStr = new String [allPlaylist.size()];
             playlistStr = allPlaylist.toArray(playlistStr);
             setListAdapter(new ArrayAdapter<String>(this, android.R.id.text1,android.R.layout.simple_list_item_1,playlistStr));
        	
        }
       
        
        btnAddPlaylist.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				Intent i = new Intent(PlaylistManagerActivity.this, AddPlaylist.class);
				startActivityForResult(i, 100);
				
			}
		});
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	if(requestCode == 100)
    	{
    		
    	}
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_playlist_manager, menu);
        return true;
    }
}
